(function() {

	// IE:styleFloat
	// FF:cssFloat
	// ALL:clear
	var QuickUI = window.QuickUI = new Object();
	// QuickUI的工具类
	QuickUI.util = (function() {

	})();

	QuickUI.domReady = function(fn) {
		addEvent(window, "load", fn);
	};

	// 一个内置的_Panel,用于支持Window的显示
	var _Panel = (function() {
		function init(id, config) {

			if (typeof id != "string") {
				// alert(id);
				if (typeof id == "object") {
					config = id;
					id = " ";

				} else {
					throw new Error("Window类的第一个参数为字符串！");
				}
			} else {
				if (config == undefined) {
					config = new Object();
				}
			}

			this.id = id;
			this.config = config;
			this.node = add_Panel.call(this);

		}

		function add_Panel() {
			var isIE6 = /msie 6/i.test(navigator.userAgent);
			var isIE7 = /msie 7/i.test(navigator.userAgent);
			if (typeof this.id != "string") {
				if (typeof this.id == "object") {
					this.config = this.id;
					this.id = " ";

				} else {
					throw new Error("Window类的第一个参数为字符串！");
				}
			} else {
				var DefaultId = this.id;
			}

			var DefaultWidth = 400;
			var DefaultHeight = 100;
			var DefaultPosTop = 0;
			var DefaultPosLeft = 0;
			var panelName = "QuickUI_panel";
			// 最上层Div包含panelDiv和一个panelDivCover
			var panelIEWarp = document.createElement("div");
			panelIEWarp.style.position = "absolute";
			panelIEWarp.className = "panelIEWarp";

			panelIEWarp.style.zIndex = 999;

			var panelDivCover = document.createElement("div");
			panelDivCover.style.position = "absolute";
			panelDivCover.style.top = 0 + "px";
			panelDivCover.style.left = 0 + "px";
			panelDivCover.style.border = "1px dashed green";
			panelDivCover.style.zIndex = "2";
			panelDivCover.className = "panelDivCover";
			panelDivCover.style.display = "none";

			var panelDiv = document.createElement("div");

			panelIEWarp.id = this.id || DefaultId;

			panelDiv.className = panelName;
			panelDiv.style.position = "absolute";

			if (this.config == undefined || this.config.width == undefined) {
				panelDiv.style.width = DefaultWidth + "px";
				panelDivCover.style.width = DefaultWidth + "px";
			} else {
				if (this.config.width < 400) {
					panelDiv.style.width = DefaultWidth + "px";
					panelDivCover.style.width = DefaultWidth + "px";
				} else {
					panelDiv.style.width = this.config.width + "px";
					panelDivCover.style.width = this.config.width + "px";
				}
			}
			if (this.config == undefined || this.config.height == undefined) {
				panelDiv.style.height = DefaultHeight + "px";
				panelDivCover.style.height = DefaultHeight + "px";
			} else {
				if (this.config.height < 100) {
					panelDiv.style.height = DefaultHeight + "px";
					panelDivCover.style.height = DefaultHeight + "px";
				} else {
					panelDiv.style.height = this.config.height + "px";
					panelDivCover.style.height = this.config.height + "px";
				}

			}
			if (this.config == undefined || this.config.top == undefined) {
				panelIEWarp.style.top = DefaultPosTop + "px";
			} else {
				panelIEWarp.style.top = this.config.top + "px";
			}
			if (this.config == undefined || this.config.left == undefined) {
				panelIEWarp.style.left = DefaultPosLeft + "px";
			} else {
				panelIEWarp.style.left = this.config.left + "px";
			}

			panelDiv.style.zIndex = 1;
			// panelDiv.style.borderRadius = "8px";
			// panelDiv.style.boxShadow = "3px 3px 5px #888888";
			// panelDiv.style.backgroundColor = "red";
			// panelDiv.style.display = "none";
			panelDiv.className = "QuickUI_Panel";

			var borderTopleft = new Border("topleft", panelDiv, this.config);
			var borderTop = new Border("top", panelDiv, this.config);
			var borderTopright = new Border("topright", panelDiv, this.config);
			var borderLeft = new Border("left", panelDiv, this.config);
			var borderCenter = new Border("center", panelDiv, this.config);
			var borderRight = new Border("right", panelDiv, this.config);
			var borderBottomleft = new Border("bottomleft", panelDiv,
					this.config);
			var borderBottom = new Border("bottom", panelDiv, this.config);
			var borderBottomright = new Border("bottomright", panelDiv,
					this.config);

			if (isIE6 || isIE7) {
				borderTopleft.setOpa("alpha(opacity=0)");
				borderTop.setOpa("alpha(opacity=0)");
				borderTopright.setOpa("alpha(opacity=0)");
				borderLeft.setOpa("alpha(opacity=0)");
				borderCenter.setBackgroundColor("transparent");
				// borderCenter.setOpa("alpha(opacity=0)");
				borderRight.setOpa("alpha(opacity=0)");
				borderBottomleft.setOpa("alpha(opacity=0)");
				borderBottom.setOpa("alpha(opacity=0)");
				borderBottomright.setOpa("alpha(opacity=0)");
			}

			panelDiv.appendChild(borderTopleft.node);
			panelDiv.appendChild(borderTop.node);
			panelDiv.appendChild(borderTopright.node);
			panelDiv.appendChild(borderLeft.node);
			panelDiv.appendChild(borderCenter.node);
			panelDiv.appendChild(borderRight.node);
			panelDiv.appendChild(borderBottomleft.node);
			panelDiv.appendChild(borderBottom.node);
			panelDiv.appendChild(borderBottomright.node);

			panelIEWarp.appendChild(panelDiv);
			panelIEWarp.appendChild(panelDivCover);

			return panelIEWarp;
		}

		return init;
	})();
	// 内置，用于支持_Panel的显示
	var Border = (function() {

		var DefaultWidth = "7px";
		var DefaultHeight = "7px";
		function init(type, continer, config) {
			this.type = type;
			this.continer = continer;
			this.config = config;
			this.node = createBorder.call(this);
		}

		init.prototype = {
			setClassName : function(cn) {
				this.node.className = cn;
			},
			setBackground : function(url) {
				this.node.style.backgroundImage = url;
			},
			setOpa : function(opa) {
				this.node.style.filter = opa;
			},
			setBackgroundColor : function(color) {
				this.node.style.backgroundColor = color;
			}
		};

		// 创建边框
		function createBorder() {
			var me = this;
			var isIE6 = /msie 6/i.test(navigator.userAgent);
			var isIE7 = /msie 7/i.test(navigator.userAgent);
			if (isHTMLElement(this.continer)) {
				var borderDiv = document.createElement("div");
				var resizeable = true;
				if (this.config == undefined
						|| this.config.resizeable == undefined) {
					resizeable = true;
				} else {

					resizeable = this.config.resizeable;
				}
				if (!+"\v1") {
					borderDiv.style.overflow = "hidden";
					borderDiv.style.styleFloat = "left";
				} else {
					borderDiv.style.cssFloat = "left";
				}
				if (isIE6 || isIE7) {
					borderDiv.style.backgroundColor = "white";
				}

				switch (this.type) {
					case "topleft" :
						borderDiv.className = "panel_border_topleft";
						borderDiv.style.width = DefaultWidth;
						borderDiv.style.height = DefaultHeight;

						// borderDiv.style.backgroundImage =
						// "url(../BaseImage/border_topleft.gif)";
						break;
					case "top" :
						borderDiv.className = "panel_border_top";
						borderDiv.style.width = (getStyle(this.continer,
								"width") - 14)
								+ "px";
						borderDiv.style.height = DefaultHeight;

						// borderDiv.style.backgroundImage =
						// "url(../BaseImage/border_top.gif)";
						if (resizeable) {
							borderDiv.style.cursor = "s-resize";
						}
						break;
					case "topright" :
						borderDiv.className = "panel_border_topright";
						borderDiv.style.width = DefaultWidth;
						borderDiv.style.height = DefaultHeight;
						// borderDiv.style.backgroundImage =
						// "url(../BaseImage/border_topright.gif)";
						if (resizeable) {
							borderDiv.style.cursor = "ne-resize";
						}
						break;
					case "left" :
						borderDiv.className = "panel_border_left";
						borderDiv.style.width = DefaultWidth;
						borderDiv.style.height = (getStyle(this.continer,
								"height") - 14)
								+ "px";
						// borderDiv.style.backgroundImage =
						// "url(../BaseImage/border_left.gif)";
						if (resizeable) {
							borderDiv.style.cursor = "w-resize";
						}
						break;
					case "center" :
						borderDiv.className = "panel_center";
						borderDiv.style.width = (getStyle(this.continer,
								"width") - 14)
								+ "px";
						borderDiv.style.height = (getStyle(this.continer,
								"height") - 14)
								+ "px";
						if (!+"\v1") {
							if (isIE6 || isIE7) {

							} else {
								borderDiv.style.filter = "progid:DXImageTransform.Microsoft.Shadow(color='#888888', Direction=135, Strength=5);";
							}

						} else {
							borderDiv.style.borderTopRightRadius = "7px";
							borderDiv.style.boxShadow = "3px 3px 5px #888888";
						}

						// borderDiv.style.backgroundColor = "#75afe8";
						borderDiv.style.overflow = "hidden";
						break;
					case "right" :
						borderDiv.className = "panel_border_right";
						borderDiv.style.width = DefaultWidth;
						borderDiv.style.height = (getStyle(this.continer,
								"height") - 14)
								+ "px";
						// borderDiv.style.backgroundImage =
						// "url(../BaseImage/border_right.gif)";
						if (resizeable) {
							borderDiv.style.cursor = "e-resize";
						}
						break;
					case "bottomleft" :
						borderDiv.className = "panel_border_bottomleft";
						borderDiv.style.width = DefaultWidth;
						borderDiv.style.height = DefaultHeight;
						// borderDiv.style.backgroundImage =
						// "url(../BaseImage/border_bottomleft.gif)";
						if (resizeable) {
							borderDiv.style.cursor = "ne-resize";
						}
						break;
					case "bottom" :
						borderDiv.className = "panel_border_bottom";
						borderDiv.style.width = (getStyle(this.continer,
								"width") - 14)
								+ "px";
						borderDiv.style.height = DefaultHeight;
						// borderDiv.style.backgroundImage =
						// "url(../BaseImage/border_bottom.gif)";
						if (resizeable) {
							borderDiv.style.cursor = "s-resize";
						}
						break;
					case "bottomright" :
						borderDiv.className = "panel_border_bottomright";
						borderDiv.style.width = DefaultWidth;
						borderDiv.style.height = DefaultHeight;
						// borderDiv.style.backgroundImage =
						// "url(../BaseImage/border_bottomright.gif)";
						if (resizeable) {
							borderDiv.style.cursor = "se-resize";
						}
						break;
					default :
						throw new Error("border类型错误!");
						break;
				}

				if (resizeable) {
					/*
					 * addEvent(borderDiv,"mousedown",function(e){
					 * //dragBorder(e,this,me.continer);
					 * dragBorder.call(this,e,this,me.continer); });
					 */

					borderDiv.onmousedown = function(e) {
						dragBorder.call(this, e, this, me.continer);
					};
				}

				return borderDiv;

			} else {
				throw new Error("Border的构造函数的第二个参数必须为一个HTML元素");
				return null;
			}

		}
		// 边框拖拽
		function dragBorder(e, borderDiv, container) {
			// container.className = "QuickUI_panel"
			e = e || window.event;

			var isChrome = window.navigator.userAgent.indexOf("Chrome");
			var panelIEWarp = container.parentNode;
			var panelDivCorver = getByClass(container.parentNode,
					"panelDivCover")[0];
			var panelDivCorverTop = getStyle(panelDivCorver, "top");
			var panelDivCorverLeft = getStyle(panelDivCorver, "left");
			var panelDivCorverHeight = getStyle(panelDivCorver, "height");
			var panelDivCorverWidth = getStyle(panelDivCorver, "width");
			var caX = e.clientX;
			var caY = e.clientY;

			if (borderDiv.className != "panel_center"
					&& borderDiv.className != "panel_border_topleft") {
				panelDivCorver.style.display = "block";

				document.onmousemove = move;
				document.onmouseup = up;

				// 这段要放在if里面防止IE内存泄漏
				// 这里的this指向边框
				if (this.setCapture) {
					this.setCapture();
				}
			}

			function move(e) {
				e = e || window.event;

				switch (borderDiv.className) {

					case "panel_border_top" :
						if ((caY - e.clientY) > getStyle(container.parentNode,
								"top")) {
							panelDivCorver.style.top = -getStyle(
									container.parentNode, "top")
									+ "px";
						} else if (getStyle(panelDivCorver, "height") <= 50) {
							panelDivCorver.style.top = getStyle(container,
									"height")
									- 50 + "px";
						} else {
							panelDivCorver.style.top = -(panelDivCorverTop + (caY - e.clientY))
									+ "px";
						}
						// document.getElementById("y").innerHTML = e.clientY;

						if (e.clientY <= 0) {
							panelDivCorver.style.height = panelDivCorverHeight
									+ (caY - e.clientY) + e.clientY - 2 + "px";
						} else {

							var h = panelDivCorverHeight + (caY - e.clientY);
							if (h > 0) {
								panelDivCorver.style.height = h + "px";
							}
						}

						if (getStyle(panelDivCorver, "height") <= 50) {
							panelDivCorver.style.height = "50px";

						}
						if (getStyle(panelDivCorver, "top") >= getStyle(
								container, "height")) {
							// alert(getStyle(panelDivCorver,"top"));
							panelDivCorver.style.top = getStyle(container,
									"height")
									- 50 + "px";
							panelDivCorver.style.height = "50px";
						}

						break;
					case "panel_border_topright" :
						if ((caY - e.clientY) > getStyle(container.parentNode,
								"top")) {
							panelDivCorver.style.top = -getStyle(
									container.parentNode, "top")
									+ "px";
							panelDivCorver.style.width = panelDivCorverWidth
									+ (e.clientX - caX) + "px";
						} else if (getStyle(panelDivCorver, "height") <= 50) {
							panelDivCorver.style.top = getStyle(container,
									"height")
									- 50 + "px";
						} else {
							panelDivCorver.style.top = -(panelDivCorverTop + (caY - e.clientY))
									+ "px";
						}

						if (getStyle(panelDivCorver, "top") >= getStyle(
								container, "height")) {
							// alert(getStyle(panelDivCorver,"top"));
							panelDivCorver.style.top = getStyle(container,
									"height")
									- 50 + "px";
							panelDivCorver.style.height = "50px";
						}
						if (getStyle(panelDivCorver, "width") <= 50) {
							panelDivCorver.style.width = "50px";
						}

						if (e.clientY <= 0) {
							panelDivCorver.style.height = panelDivCorverHeight
									+ (caY - e.clientY) + e.clientY - 2 + "px";
						} else {

							var h = panelDivCorverHeight + (caY - e.clientY);
							var w = panelDivCorverWidth + (e.clientX - caX);
							if (w <= 50) {
								w = 50;
							}
							if (h <= 50) {
								h = 50;
							}
							if (h > 0) {
								panelDivCorver.style.height = h + "px";
								panelDivCorver.style.width = w + "px";
							}

						}

						break;
					case "panel_border_left" :
						if ((caX - e.clientX) > getStyle(container.parentNode,
								"left")) {
							panelDivCorver.style.left = -getStyle(
									container.parentNode, "left")
									+ "px";
						} else if (getStyle(panelDivCorver, "width") <= 50) {
							panelDivCorver.style.left = getStyle(container,
									"width")
									- 50 + "px";
						} else {
							panelDivCorver.style.left = -(panelDivCorverLeft + (caX - e.clientX))
									+ "px";
						}

						if (e.clientX > getStyle(container.parentNode, "left")
								+ getStyle(container, "width") - 51) {
							panelDivCorver.style.width = 50 + "px";
						} else {
							var w = panelDivCorverWidth + (caX - e.clientX);
							panelDivCorver.style.width = w + "px";
						}
						break;
					case "panel_border_right" :

						if (e.clientX < getStyle(container.parentNode, "left")
								+ 51) {
							panelDivCorver.style.width = "50px";
						} else {
							var w = panelDivCorverWidth + (e.clientX - caX);
							panelDivCorver.style.width = w + "px";
						}

						break;
					case "panel_border_bottomleft" :
						if ((caX - e.clientX) > getStyle(container.parentNode,
								"left")) {
							panelDivCorver.style.left = -getStyle(
									container.parentNode, "left")
									+ "px";
						} else if (getStyle(panelDivCorver, "width") <= 50) {
							panelDivCorver.style.left = getStyle(container,
									"width")
									- 50 + "px";
						} else {
							panelDivCorver.style.left = -(panelDivCorverLeft + (caX - e.clientX))
									+ "px";
						}

						if (e.clientX > getStyle(container.parentNode, "left")
								+ getStyle(container, "width") - 51) {
							panelDivCorver.style.width = 50 + "px";
						} else {
							var w = panelDivCorverWidth + (caX - e.clientX);
							panelDivCorver.style.width = w + "px";
						}
						if (e.clientY < getStyle(container.parentNode, "top")
								+ 50) {
							panelDivCorver.style.height = "50px";
						} else {
							var h = panelDivCorverHeight + (e.clientY - caY);
							panelDivCorver.style.height = h + "px";
						}

						break;
					case "panel_border_bottom" :
						if (e.clientY < getStyle(container.parentNode, "top")
								+ 50) {
							panelDivCorver.style.height = "50px";

						} else {
							var h = panelDivCorverHeight + (e.clientY - caY);
							panelDivCorver.style.height = h + "px";
						}

						break;
					case "panel_border_bottomright" :

						if (e.clientX < getStyle(container.parentNode, "left")
								+ 50) {
							panelDivCorver.style.width = 50 + "px";
						} else {
							var w = panelDivCorverWidth + (e.clientX - caX);
							panelDivCorver.style.width = w + "px";
						}
						if (e.clientY < getStyle(container.parentNode, "top")
								+ 50) {
							panelDivCorver.style.height = "50px";
						} else {
							var h = panelDivCorverHeight + (e.clientY - caY);
							panelDivCorver.style.height = h + "px";
						}
						break;
					default :
						break;

				}
			}

			function up(e) {
				e = e || window.event;
				// alert(this);
				// 这里的this指向document
				if (this.releaseCapture) {
					this.releaseCapture();
				}
				document.onmousemove = null;
				document.onmouseup = null;

				container.style.width = panelDivCorver.style.width;
				container.style.height = panelDivCorver.style.height;
				switch (borderDiv.className) {

					case "panel_border_top" :
					case "panel_border_topright" :
						container.parentNode.style.top = getStyle(
								panelDivCorver, "top")
								+ getStyle(container.parentNode, "top") + "px";
						panelDivCorver.style.top = "0px";
						break;
					case "panel_border_bottomleft" :
					case "panel_border_left" :
						container.parentNode.style.left = getStyle(
								panelDivCorver, "left")
								+ getStyle(container.parentNode, "left") + "px";
						panelDivCorver.style.left = "0px";
						break;
					default :
						break;
				}

				getByClass(container, "panel_border_top")[0].style.width = getStyle(
						container, "width")
						- 14 + "px";
				getByClass(container, "panel_border_left")[0].style.height = getStyle(
						container, "height")
						- 14 + "px";
				getByClass(container, "panel_center")[0].style.width = getStyle(
						container, "width")
						- 14 + "px";
				getByClass(container, "panel_center")[0].style.height = getStyle(
						container, "height")
						- 14 + "px";
				getByClass(container, "panel_border_right")[0].style.height = getStyle(
						container, "height")
						- 14 + "px";
				getByClass(container, "panel_border_bottom")[0].style.width = getStyle(
						container, "width")
						- 14 + "px";
				var panel_center = getByClass(container, "panel_center")[0];
				getByClass(container, "panel_content")[0].style.width = getStyle(
						panel_center, "width")
						- 2 + "px";
				var h = getStyle(panel_center, "height") - 42;
				if (h <= 0) {
					h = 0;
				}
				getByClass(container, "panel_content")[0].style.height = h
						+ "px";
				panelDivCorver.style.display = "none";

				getByClass(container, "panel_title_bar")[0].style.width = getStyle(
						panel_center, "width")
						+ "px";
				getByClass(container, "title_border_top")[0].style.width = getStyle(
						panel_center, "width")
						- 14 + "px";
				getByClass(container, "title_center")[0].style.width = getStyle(
						panel_center, "width")
						+ "px";
				// getByClass(container,"panel_content")[0]

			}

		}

		return init;
	})();
	//树的节点
	QuickUI.TreeNode = (function(){
		
		function init(nodeText, level, isLastOne, hasNext, parent, handler,isOpen){
			/**
			 * 节点名称
			*/
			if(nodeText == "" || nodeText == undefined){
				throw new Error("请输入节点名称！");
			}
			this.nodeText = nodeText;
			/**
			 * 节点级别
			*/
			this.level = level;
			/**
			 * 是否是最后一个
			*/
			this.isLastOne = isLastOne;
			/**
			 * 有没有下一个
			*/
			this.hasNext = hasNext;
			/**
			 * 该节点的父节点
			*/
			this.parent = parent;
			/**
			 * 节点行为
			*/
			this.handler = handler;
			/**
			 * 节点是否打开
			*/
			this.isOpen = isOpen;
			/**
			 * 节点的子节点集合
			*/
			this.childrens = [];
			/**
			 * 节点的数据即tr节点
			*/
			if(this.level){
				this.tag = createNode.call(this);
			}
		
		}
		
		
		init.prototype = {
			addChild:function(node){
				node.parent = this;
				this.childrens.push(node);
				//alert(this.tag);
			}
			
		};
		//创建tr标签
		function createNode(){
			var me = this;
			var tr = document.createElement("tr");
			tr.current = false;
			var td = document.createElement("td");
			var div = document.createElement("div");
			imgs = [];
			for (var i = 0; i < this.level; i++) {
				var img = document.createElement("span");
				img.style.display = "inline-block";
				imgs.push(img);
			}

			for (var j = imgs.length - 1; j >= 0; j--) {
				if (j == imgs.length - 1) {
					if (this.isLastOne) {
						if (this.hasNext) {
							// imgs[j].src = "../BaseImage/tree/treeLineTo.gif";
							imgs[j].className = "treeLineTo";
						} else {
							// imgs[j].src =
							// "../BaseImage/tree/treeLineToC.gif";
							imgs[j].className = "treeLineToC"
						}
					} else {
						if (this.hasNext) {

							// imgs[j].src = "../BaseImage/tree/treeClose.gif";
							imgs[j].className = "tree_open";

						} else {
							// imgs[j].src = "../BaseImage/tree/treeRootC.gif";
							imgs[j].className = "tree_root";
							// imgs[j].isOpen = true;
						}
						addEvent(imgs[j], "click", function() {

							changeColorC.call(me, me.isOpen);

						});
					}
				} else {
					if (j == 0) {
						// imgs[j].src = "../BaseImage/tree/treeNone.gif";
						//imgs[j].className = "treeNone";
						//递归检测根节点是否有下一个元素
						//alert(rootNodeHasNext(this));
						if(rootNodeHasNext(this)){
							imgs[j].className = "treeLine";
						}else{
							imgs[j].className = "treeNone";
						}
						
					} else {
						if (this.parent.hasNext) {
							// imgs[j].src = "../BaseImage/tree/treeLine.gif";
							imgs[j].className = "treeLine";
						} else {
							// alert(this.parent.nodeText);
							// imgs[j].src="../BaseImage/tree/treeNone.gif";
							imgs[j].className = "treeNone";
						}

					}

				}

			}

			if (this.isLastOne) {
				var lastImage = document.createElement("span");
				lastImage.className = "treeWen";
				// lastImage.src = "../BaseImage/tree/treeWen.gif";
				imgs.push(lastImage);
			} else {
				var lastImage = document.createElement("span");
				lastImage.className = "treeDoc";
				// lastImage.src = "../BaseImage/tree/treeDoc.gif";
				imgs.push(lastImage);
			}

			for (var k = 0; k < imgs.length; k++) {
				div.appendChild(imgs[k]);
			}

			var a = document.createElement("a");
			a.className = "treeItem_text";
			a.innerHTML = this.nodeText;

			if (this.isLastOne) {
				if (this.handler) {
					this.handler.call(a);
				} else {
					lastOneA.call(a);
				}
			} else {
				if(this.handler){
					this.handler.call(a);
				}else{
					noLastOneA.call(a);
				}
			}

			div.appendChild(a);

			td.appendChild(div);
			tr.appendChild(td);

			addEvent(tr, "mouseover", changeColorA);
			addEvent(tr, "mouseout", changeColorB);
			addEvent(a, "click", function() {
						changeColorD.call(me);
					});
			return tr;
			
		}
		
		//递归获取根节点
		function rootNodeHasNext(node){
			
			if(node.parent){
				//注意要用return 不然返回undefined;
				return rootNodeHasNext(node.parent);
			}else{
				if(node.hasNext){
					return true;
				}else{
					return false;
				}
			}
		}
		
		function changeColorD() {
			if (!this.isLastOne) {
				var img1 = getByClass(this.tag, "tree_open")[0];
				var img2 = getByClass(this.tag, "tree_root")[0];
				if (img1) {
					if (this.isOpen) {
						changeColorC.call(this, this.isOpen);
						this.isOpen = false;
					} else {
						changeColorC.call(this, this.isOpen);
						this.isOpen = true;
					}

				} else {
					if (this.isOpen) {
						changeColorC.call(this, this.isOpen);
						this.isOpen = false;
					} else {
						changeColorC.call(this, this.isOpen);
						this.isOpen = true;
					}

				}
			} else {
				var tr = this.tag;
				var table = tr.parentNode;
				var trs = table.getElementsByTagName("tr");
				for (var i = 0; i < trs.length; i++) {

					if (trs[i] == tr) {
						continue;
					} else {
						trs[i].style.backgroundColor = "transparent";
						trs[i].current = false;
					}
				}
				tr.current = true;
			}

		}

		function changeColorC(isOpen) {

			var tr = this.tag;
			var table = tr.parentNode;
			var trs = table.getElementsByTagName("tr");
			var imgs = tr.getElementsByTagName("span");
			var img = imgs[imgs.length - 1];
			for (var i = 0; i < trs.length; i++) {

				if (trs[i] == tr) {
					continue;
				} else {
					trs[i].style.backgroundColor = "transparent";
					trs[i].current = false;
				}
			}
			tr.current = true;

			var changeImg1 = getByClass(this.tag, "tree_open")[0];
			var changeImg2 = getByClass(this.tag, "tree_root")[0];

			var changeImg3 = getByClass(this.tag, "treeClose")[0];
			var changeImg4 = getByClass(this.tag, "treeRootO")[0];

			if (changeImg1) {

				if (isOpen) {
					// changeImg1.src = "../BaseImage/tree/treeClose.gif";
					changeImg1.className = "tree_open";
					this.isOpen = false;
				} else {
					// changeImg1.src = "../BaseImage/tree/treeOpen.gif";
					changeImg1.className = "treeClose";
					this.isOpen = true;
				}
			}

			if (changeImg3) {
				if (isOpen) {
					// changeImg1.src = "../BaseImage/tree/treeClose.gif";
					changeImg3.className = "tree_open";
					this.isOpen = false;
				} else {
					// changeImg1.src = "../BaseImage/tree/treeOpen.gif";
					changeImg3.className = "treeClose";
					this.isOpen = true;
				}

			}

			if (changeImg2) {
				if (isOpen) {
					// changeImg2.src = "../BaseImage/tree/treeRootC.gif";
					changeImg2.className = "tree_root";
					this.isOpen = false;
				} else {
					// changeImg2.src = "../BaseImage/tree/treeRootO.gif";
					changeImg2.className = "treeRootO";
					this.isOpen = true;
				}
			}

			if (changeImg4) {
				if (isOpen) {
					// changeImg2.src = "../BaseImage/tree/treeRootC.gif";
					changeImg4.className = "tree_root";
					this.isOpen = false;
				} else {
					// changeImg2.src = "../BaseImage/tree/treeRootO.gif";
					changeImg4.className = "treeRootO";
					this.isOpen = true;
				}
			}

			if (isOpen) {
				// img.src = "../BaseImage/tree/treeDoc.gif";
				img.className = "treeDoc";
				if (changeImg1) {
					this.isOpen = false;
				} else {
					this.isOpen = false;
				}
			} else {
				// img.src = "../BaseImage/tree/treeDocOpen.gif";
				img.className = "treeDocOpen";
				if (changeImg1) {
					this.isOpen = true;
				} else {
					this.isOpen = true;
				}
			}

			showOrHideNode.call(this, this);

		}

		function showOrHideNode(treeNode) {

			// 逐级检查是否Open
			if (!treeNode.isOpen) {

				var allChilds = getAllChilds([], treeNode);
				for (var i = 0; i < allChilds.length; i++) {

					closeNode(allChilds[i]);
					// allChilds[i].node.style.display = "none";
				}
			} else {
				var allChildss = getAllOpenChilds([], treeNode);
				for (var j = 0; j < allChildss.length; j++) {
					// alert(allChildss[j].nodeText);
					allChildss[j].tag.style.display = "block";
					openNode(allChildss[j]);
				}
			}

		}
		// 打开节点的动画
		function openNode(nodeObject) {
			var div = nodeObject.tag.getElementsByTagName("div")[0];
			var timer1 = null;
			div.style.height = "0px";
			div.style.display = "block";
			clearInterval(timer1);
			timer1 = setInterval(function() {
						div.style.height = getStyle(div, "height") + 5 + "px";
						// alert(getStyle(div,"height"));
						if (getStyle(div, "height") >= 30) {

							clearInterval(timer1);
						}
					}, 10);

		}
		// 关闭节点的动画
		function closeNode(nodeObject) {
			var div = nodeObject.tag.getElementsByTagName("div")[0];
			var timer1 = null;
			div.style.height = "30px";
			clearInterval(timer1);
			timer1 = setInterval(function() {
						div.style.height = getStyle(div, "height") - 5 + "px";
						if (getStyle(div, "height") <= 0) {

							clearInterval(timer1);
							nodeObject.tag.style.display = "none";
						}

					}, 10);

		}

		// 获取所有子元素用于关闭子元素
		function getAllChilds(allChilds, parent) {
			
			for (var i = 0; i < parent.childrens.length; i++) {
				allChilds.push(parent.childrens[i]);
				// parent = parent.childs[i];
				getAllChilds(allChilds, parent.childrens[i]);
			}

			return allChilds;

		}
		// 获取打开中的子元素，用于展开子元素
		function getAllOpenChilds(allChilds, parentT) {
			
			for(var j=0; j<parentT.childrens.length;j++){
				parentT.childrens[j].parent =parentT;
			}
			
			for (var i = 0; i < parentT.childrens.length; i++) {
//这行有改动一个"!"
				if (!parentT.childrens[i].parent.isOpen) {
					continue;
				} else {
					allChilds.push(parentT.childrens[i]);
				}
				// parent = parent.childs[i];
				getAllOpenChilds(allChilds, parentT.childrens[i]);
			}

			return allChilds;
		}

		function changeColorA() {

			this.style.backgroundColor = "#EAEAEA";
		}

		function changeColorB() {
			if (!this.current) {
				this.style.backgroundColor = "transparent";
			}

		}

		function lastOneA() {
			this.href = "javascript:void(0)";
			// this.target = "_frameName";
		}

		function noLastOneA() {
			this.href = "javascript:void(0)";
		}
		
		
		
		return init;
	
	})();	
	QuickUI.Tree = (function(){
		function init(treeId, config) {
			if (typeof treeId != "string") {
				// alert(id);
				if (typeof treeId == "object") {
					config = treeId;
					treeId = " ";

				} else {
					throw new Error("Tree类的第一个参数为字符串！");
				}
			} else {
				if (config == undefined) {
					config = new Object();
				}
			}
			this.level = 1;
			this.rootNodes = [];
			this.treeId = treeId;
			this.config = config;
			this.tag = createTree.call(this);
		}
		
		function createTree(rootNodes) {

			var DefaultWidth = 200;
			var DefaultPosTop = 0;
			var DefaultPosLeft = 0;

			var treePanel = document.createElement("div");
			treePanel.className = "QuickUI_treePanel";

			if (this.config == undefined || this.config.width == undefined) {
				treePanel.style.width = DefaultWidth + "px";
			} else {
				if (this.config.width < 400) {
					treePanel.style.width = DefaultWidth + "px";
				} else {
					treePanel.style.width = this.config.width + "px";
				}
			}
			if (this.config == undefined || this.config.height == undefined) {
				treePanel.style.height = "auto";
			} else {
				if (this.config.height < 100) {
					treePanel.style.height = "auto";
				} else {
					treePanel.style.height = this.config.height + "px";
				}

			}
			if (this.config == undefined || this.config.top == undefined) {
				treePanel.style.top = DefaultPosTop + "px";
			} else {
				treePanel.style.top = this.config.top + "px";
			}
			if (this.config == undefined || this.config.left == undefined) {
				treePanel.style.left = DefaultPosLeft + "px";
			} else {
				treePanel.style.left = this.config.left + "px";
			}

			var treeTable = document.createElement("table");
			treeTable.className = "treeTable";
			treeTable.setAttribute("border", "0");
			treeTable.setAttribute("cellpadding", "0");
			treeTable.setAttribute("cellspacing", "0");

			var tBody = document.createElement("tbody");
			
			if(rootNodes){
				var arr = [];
				var all = nodeStructure.call(this,rootNodes,arr);
				addChild.call(this,rootNodes);
				
				for(var i=0;i<all.length;i++){
					tBody.appendChild(all[i]);
				}
				
			}else{
				if(this.config && this.config.root && this.config.root.children){
				
					var nodes = [];
					var parent = undefined;
					var hasNext = null;
					var isLastOne = null;
					var all = null;
					//if(this.config.root.children)
					
					if(this.config.root.children)
					var arr = this.config.root.children;
					//(rootNode, nodes, isLastOne, hasNext, parent, isOpen)
					var all = [];
					for(var i=0;i<arr.length;i++){
						
						if(i==arr.length-1){
							hasNext = false;
						}else{
							hasNext = true;
						}
						nodes = [];
						var all1 = createNode.call(this, arr[i], nodes, false,
							hasNext, parent, false);
						var all1Node = addChild.call(this,all1);
						all.push(all1Node);
						this.level--;
						
						
					}
					//alert(this.rootNodes.length);
	
					for(var l=0;l<all.length;l++){
						for(var m=0;m<all[l].length;m++){
							tBody.appendChild(all[l][m].tag);
						}
					}
				
				
				
				}
			}
			
			treeTable.appendChild(tBody);
			treePanel.appendChild(treeTable);

			return treePanel;

		}
		
		
		//为节点添加tag属性
		function nodeStructure(rootNodes,arr){
			//alert(this.level);
			if(rootNodes){
				for(var i=0;i<rootNodes.length;i++){				
				
					//(nodeText, level, isLastOne, hasNext, parent, handler,isOpen)
					//var level = 1;
					var isLastOne = false;
					var hasNext = false;
					if(rootNodes[i].childrens && rootNodes[i].childrens.length>0){
						isLastOne = false;
					}else{
						isLastOne = true;
					}
					if(i==rootNodes.length-1){
						hasNext = false;
					}else{
						hasNext = true;
					}
					var parent = rootNodes[i].parent;
					var handler = undefined;
					var children = rootNodes[i].childrens;
					if(isLastOne){
						handler = rootNodes[i].handler || function(){this.href = "javascript:void(0)";};
					}
					var isOpen = false;
					rootNodes[i] = new QuickUI.TreeNode(rootNodes[i].nodeText,this.level,isLastOne,hasNext,parent, handler,isOpen);
					rootNodes[i].childrens = children;
					
					
					
					if(rootNodes[i].parent){
						rootNodes[i].tag.style.display = "none";
					}
					arr.push(rootNodes[i].tag);
					
					
					
					this.level++;
					nodeStructure.call(this,rootNodes[i].childrens,arr);
					this.level--;
				
				}
				
			}
			
			return arr;
					
		}
		
		//递归列出目录结构
		function createNode(rootNode, nodes, isLastOne, hasNext, parent, isOpen) {
			//var level = 1;
			if (rootNode.children) {
				isLastOne = false;
			} else {
				isLastOne = true;
				
			}
			var handler = rootNode.handler;
			isOpen = false;

			var node1 = new QuickUI.TreeNode(rootNode.text, this.level, isLastOne,
					hasNext, parent, handler, isOpen);
			if (node1.parent) {
				node1.tag.style.display = "none";
			}else{
				this.rootNodes.push(node1);
				//alert(node1.nodeText);
			}
			
			nodes.push(node1);
			// 指定node的父亲节点
			parent = nodes[nodes.length - 1];

			this.level++;
			if (rootNode.children) {
				for (var i = 0; i < rootNode.children.length; i++) {
					if (i == rootNode.children.length - 1) {
						hasNext = false;
					} else {
						hasNext = true;
					}
					if (node1.parent == parent) {
						parent.childs.push(node1);
					}

					createNode.call(this, rootNode.children[i], nodes,
							isLastOne, hasNext, parent, handler, isOpen);

					this.level--;
				}

			}
			// parent.childs.push(node1);
			//nodes = [];
			return nodes;
			

		}
		
		// 为每个teeeNode对象，添加childs数组
		function addChild(all) {

			for (var i = 0; i < all.length; i++) {
				for (var j = 0; j < all.length; j++) {

					if (all[i] == all[j]) {

						continue;
					} else {
						if (all[i] == all[j].parent) {
							all[i].childrens.push(all[j]);
						}
					}

				}
			}
			return all;
		}
		
		init.prototype = {
			show : function() {
				var bodyNode = document.getElementsByTagName("body")[0];
				bodyNode.appendChild(this.tag);
			},
			hide : function() {
				var bodyNode = document.getElementsByTagName("body")[0];
				bodyNode.removeChild(this.tag);
			},
			addRootNode:function(node){
				this.rootNodes.push(node);
				
				//重新初始化视图
				this.tag = createTree.call(this,this.rootNodes);
				//alert(this.rootNodes.length);
				
				//alert(this.rootNodes[3].tag);
				//更新数据
				//this.tag = createTree.call(this);
			}
		};
		
		return init;
	})();
	
	// Window类用于显示一个窗口，其参数配置请查看开发文档
	QuickUI.Window = (function() {

		function init(id, config) {

			this.newMethod = _Panel;
			this.newMethod(id, config);
			delete this.newMethod;

			// 点击切换zIndex
			divClick.call(this);
			// 添加标题栏
			addTitleBar.call(this);
			// 添加工具栏工具
			addTools.call(this);
		}

		init.prototype = {
			open : function() {
				var bodyNode = document.getElementsByTagName("body")[0];
				bodyNode.appendChild(this.node);
			},
			close : function() {
				var bodyNode = document.getElementsByTagName("body")[0];
				bodyNode.removeChild(this.node);
			},
			hide : function() {
				this.node.style.display = "none";
			},
			show : function() {
				this.node.style.display = "block";
			}

		};
		// 点击切换zIndex
		function divClick() {
			addEvent(this.node, "mousedown", function() {
				var allWindow = getByClass(document, "panelIEWarp");
				for (var i = 0; i < allWindow.length; i++) {
					if (allWindow[i].style.zIndex == 1000) {
						allWindow[i].style.zIndex = parseInt(allWindow[i].style.zIndex)
								- 1;
					}

				}
				if (this.style.zIndex == 999) {
					this.style.zIndex = parseInt(this.style.zIndex) + 1;
				}

			});

		}
		// 添加标题栏
		function addTitleBar() {
			var isIE6 = /msie 6/i.test(navigator.userAgent);
			var isIE7 = /msie 7/i.test(navigator.userAgent);
			var isChrome = window.navigator.userAgent.indexOf("Chrome");
			var isFirefox = window.navigator.userAgent.indexOf("Firefox");
			var node = this.node;
			var dragable = true;
			var doc = document;
			if (this.config.title) {
				// alert(this.config.title);
				var title = this.config.title;
			} else {
				var title = " ";
			}
			var panelCenter = getByClass(this.node, "panel_center")[0];
			// panelCenter.style.borderTopRightRadius = "5px";
			var container = document.createElement("div");
			container.style.width = getStyle(panelCenter, "width") + "px";
			container.className = "panel_title_bar";
			container.style.fontWeight = "bold";
			container.style.color = "white";
			// container.style.backgroundColor = "#428BCA";
			container.style.fontSize = "14px";
			// container.style.marginBottom = "5px";
			container.style.height = "40px";
			if (!+"\v1") {
				container.style.cursor = "default";
			}
			/*
			 * 为标题栏添加圆角
			 */
			var borderConfig = {
				resizeable : false
			};

			// topleft
			var borderTopLeft = new Border("topleft", container, borderConfig);
			borderTopLeft.setClassName("title_border_topleft");
			if (isIE6 || isIE7) {
				borderTopLeft.setBackgroundColor("transparent");
			}

			// top
			var borderTop = new Border("top", container, borderConfig);
			borderTop.setClassName("title_border_top");
			if (isIE6 || isIE7) {
				borderTop.setBackgroundColor("transparent");
			}

			// topright
			var borderTopRight = new Border("topright", container, borderConfig);
			borderTopRight.setClassName("title_border_topright");
			if (isIE6 || isIE7) {
				borderTopRight.setBackgroundColor("transparent");
			}
			// center
			var titleCenter = document.createElement("div");
			titleCenter.className = "title_center";
			titleCenter.style.width = container.style.width;
			titleCenter.style.height = getStyle(container, "height") - 7 + "px";
			titleCenter.style.backgroundColor = "#428BCA";
			if (!+"\v1") {
				titleCenter.style.overflow = "hidden";
				titleCenter.style.styleFloat = "left";
			} else {
				titleCenter.style.cssFloat = "left";
			}

			container.appendChild(borderTopLeft.node);
			container.appendChild(borderTop.node);
			container.appendChild(borderTopRight.node);
			// container.appendChild(titleCenter);

			/*
			 * 添加标题
			 */
			var panelTitle = document.createElement("span");
			panelTitle.className = "panel_title";
			panelTitle.setAttribute("onselectstart", "return false;");
			panelTitle.innerHTML = title;
			panelTitle.style.position = "relative";
			panelTitle.style.left = "20px";
			panelTitle.style.top = "5px";

			var panelToolBar = document.createElement("div");
			panelToolBar.className = "win_toolBar";
			panelToolBar.style.position = "absolute";
			panelToolBar.style.right = "15px";
			panelToolBar.style.top = "18px";
			var panelShutdown = document.createElement("div");
			panelShutdown.className = "panel_shutdown";
			// panelShutdown.style.position = "absolute";
			panelShutdown.style.width = "16px";
			panelShutdown.style.height = "16px";
			// panelShutdown.style.right = "10px";
			// panelShutdown.style.top = "5px";
			// panelShutdown.style.backgroundImage =
			// "url(../BaseImage/shutdown.gif)";
			panelShutdown.onmousedown = function(e) {
				e = e || window.event;
				if (!+"\v1") {
					e.cancelBubble = true;
				} else {
					e.stopPropagation();
				}
			};
			panelToolBar.appendChild(panelShutdown);
			titleCenter.appendChild(panelTitle);
			titleCenter.appendChild(panelToolBar);

			container.appendChild(titleCenter);

			// 添加panel_title_bar
			panelCenter.appendChild(container);
			// alert(getStyle(container.parentNode,"width"));

			var panel_Content = document.createElement("div");
			panel_Content.className = "panel_content";
			panel_Content.style.backgroundColor = "white";
			panel_Content.style.border = "1px solid #428BCA";
			// panel_Content.style.width = panelCenter.style.width;
			panel_Content.style.width = getStyle(panelCenter, "width") - 2
					+ "px";
			// panel_Content.style.height =
			// getStyle(panelCenter,"height")-27+"px";
			panel_Content.style.height = getStyle(panelCenter, "height") - 42
					+ "px";
			// panel_Content.style.boxShadow = "3px 3px 5px #888888";
			panelCenter.appendChild(panel_Content);

			// 关闭按钮的移入移出
			addEvent(panelShutdown, "mouseover", function() {
						// alert(this.className);
						this.className = "panel_shutdown_over";
					});
			addEvent(panelShutdown, "mouseout", function() {
						this.className = "panel_shutdown";
					});
			// 关闭按钮关闭
			addEvent(panelShutdown, "click", function() {

						var bodyNode = document.getElementsByTagName("body")[0];
						bodyNode.removeChild(node);
					});
			// 拖拽
			if (this.config.dragable) {
				if (this.config.dragable == true) {
					dragable = true;
				} else {
					dragable = false;
				}
			} else {
				dragable = false;
			}
			if (dragable) {
				// 绑定拖拽函数

				if (isChrome != -1 || isFirefox != -1) {
					container.addEventListener("mousedown", containerDown,
							false);
				} else {
					// addEvent(container,"mousedown",containerDown);
					container.onmousedown = containerDown;
				}
			}

			function getViewport() {
				return {
					width : Math.max(document.documentElement.clientWidth,
							document.documentElement.scrollWidth),
					height : Math.max(document.documentElement.clientHeight,
							document.documentElement.scrollHeight)
				};
			}

			function compareNum(x, minNum, maxNum) {
				switch (true) {
					case x < minNum :
						x = minNum;
						break;
					case x > maxNum :
						x = maxNum;
						break;
					default :
						x;
				}
				return x;
			}

			function compareNumY(x, minNum, maxNum) {
				switch (true) {
					case x < minNum :
						x = minNum;
						break;
					default :
						x;
				}
				return x;
			}

			function containerDown(e) {
				// node
				e = e || window.event;
				var isIE6 = /msie 6/i.test(navigator.userAgent);
				var isIE7 = /msie 7/i.test(navigator.userAgent);
				var QuickUI_Panel = getByClass(node, "QuickUI_Panel")[0];
				var Panel_Center = getByClass(node, "panel_center")[0];
				if (!+"\v1") {
					Panel_Center.style.filter = "alpha(opacity=60)";
				} else {
					QuickUI_Panel.style.opacity = "0.5";
				}
				var maxL = getViewport().width
						- getStyle(QuickUI_Panel, "width"), maxT = getViewport().height
						- getStyle(QuickUI_Panel, "height");
				node.startL = getStyle(node, "left");
				node.startT = getStyle(node, "top");
				// alert(e.clientX)
				node.startX = e.clientX;
				node.startY = e.clientY;
				// alert(maxL+':'+maxT+':'+L+':'+T)
				doc.onmousemove = function(e) {
					posXY(e, 0, 0, maxL, maxT);
				};
				doc.onmouseup = function() {
					if (this.releaseCapture) {
						this.releaseCapture();
					}
					if (!+"\v1") {
						if (isIE6 || isIE7) {
							Panel_Center.style.filter = "alpha(opacity=100)";
						} else {
							Panel_Center.style.filter = "progid:DXImageTransform.Microsoft.Shadow(color='#888888', Direction=135, Strength=5);";
						}

					} else {
						QuickUI_Panel.style.opacity = "1";
					}
					doc.onmousemove = null;
					doc.onmouseup = null;
					// container.onmousedown = null;
				};

				if (this.setCapture) {
					this.setCapture();
				}

				return false;
			}

			function posXY(e, minL, minT, maxL, maxT) {
				e = e || window.event;
				var x = node.startL - (node.startX - e.clientX);
				var y = node.startT - (node.startY - e.clientY);
				node.style.left = compareNum(x, minL, maxL) + 'px';
				node.style.top = compareNumY(y, minT, maxT) + 'px';
			}

		}
		// 添加工具栏
		function addTools() {
			// this.node.className = panelIEWarp

			function handlerMaxSize() {
				alert("b");
			}

			function handlerMinSize() {
				alert("c");
			}
			function handlerReflash() {
				alert("d");
			}
			function handlerPrint() {
				alert("e");
			}
			function handlerSave() {
				alert("f");
			}

			function handlerHelp() {
				alert("g");
			}

			var win_toolBar = getByClass(this.node, "win_toolBar")[0];
			if (this.config && this.config.tools) {
				var tools = this.config.tools;
				for (var i = 0; i < tools.length; i++) {
					var toolsElement = document.createElement("div");
					var allTools = win_toolBar.getElementsByTagName("div");
					if (tools[i].id) {
						switch (tools[i].id) {
							case "maxSize" :
								toolsElement.className = "win_tools_maxSize";
								addEvent(toolsElement, "mouseover", function() {
											this.className = "win_tools_maxSize_over";
										});
								addEvent(toolsElement, "mouseout", function() {
											this.className = "win_tools_maxSize";
										});
								addEvent(toolsElement, "click",
										tools[i].handler || handlerMaxSize);
								break;
							case "minSize" :
								toolsElement.className = "win_tools_minSize";
								addEvent(toolsElement, "mouseover", function() {
											this.className = "win_tools_minSize_over";
										});
								addEvent(toolsElement, "mouseout", function() {
											this.className = "win_tools_minSize";
										});
								addEvent(toolsElement, "click",
										tools[i].handler || handlerMinSize);
								break;
							case "reflash" :
								toolsElement.className = "win_tools_reflash";
								addEvent(toolsElement, "mouseover", function() {
											this.className = "win_tools_reflash_over";
										});
								addEvent(toolsElement, "mouseout", function() {
											this.className = "win_tools_reflash";
										});
								addEvent(toolsElement, "click",
										tools[i].handler || handlerReflash);
								break;
							case "print" :
								toolsElement.className = "win_tools_print";
								addEvent(toolsElement, "mouseover", function() {
											this.className = "win_tools_print_over";
										});
								addEvent(toolsElement, "mouseout", function() {
											this.className = "win_tools_print";
										});
								addEvent(toolsElement, "click",
										tools[i].handler || handlerPrint);
								break;
							case "save" :
								toolsElement.className = "win_tools_save";
								addEvent(toolsElement, "mouseover", function() {
											this.className = "win_tools_save_over";
										});
								addEvent(toolsElement, "mouseout", function() {
											this.className = "win_tools_save";
										});
								addEvent(toolsElement, "click",
										tools[i].handler || handlerSave);
								break;
							case "help" :
								toolsElement.className = "win_tools_help";
								addEvent(toolsElement, "mouseover", function() {
											this.className = "win_tools_help_over";
										});
								addEvent(toolsElement, "mouseout", function() {
											this.className = "win_tools_help";
										});
								addEvent(toolsElement, "click",
										tools[i].handler || handlerHelp);
								break;
							default :
								break;

						}
						addEvent(toolsElement, "mousedown", function(e) {
									e = e || window.event;
									if (!+"\v1") {
										e.cancelBubble = true;
									} else {
										e.stopPropagation();
									}
								});
						win_toolBar.appendChild(toolsElement);
					}
				}

			}
		}

		function addElement() {
			var continer = getByClass(this.node, "panel_center")[0];
			// alert(continer.className);
		}

		return init;
	})();

	// ================================================
	// 工具函数
	// ================================================
	function getByClass(parent, cn) {
		if (typeof cn != "string") {
			throw new Error("getByClass函数的第二个参数必须为字符串,这个字符串是html元素的class属性值！");
		}
		if (typeof parent != "object") {
			throw new Error("getByClass函数的第一个参数必须为一个html元素对象！");
		}
		var allnodes = parent.getElementsByTagName("*");
		var nodes = [];
		for (var i = 0; i < allnodes.length; i++) {
			if (allnodes[i].className == cn) {
				nodes.push(allnodes[i]);
			}
		}
		return nodes;
	}
	// 获取最终样式函数
	function getStyle(element, name) {
		var s = "";
		if (element.style[name]) {
			s = element.style[name];
			try {
				return parseInt(s);
			} catch (e) {
				return s;
			}
		} else if (element.currentStyle) {
			s = element.currentStyle[name];
			try {
				return parseInt(s);
			} catch (e) {
				return s;
			}
		} else if (document.defaultView
				&& document.defaultView.getComputedStyle) {
			name = name.replace(/([A-Z])/g, "-$1");
			name = name.toLowerCase();
			var str = document.defaultView.getComputedStyle(element, null);
			if (str) {
				s = str.getPropertyValue(name);
				try {
					return parseInt(s);
				} catch (e) {
					return s;
				}
			}
		}

	}
	// 判断是否为元素对象
	function isHTMLElement(el) {
		if (el.nodeName == undefined) {
			return false;
		} else {
			return true;
		}
	}

	function addEvent(element, type, handler) {

		// 为每一个事件处理函数赋予一个独立的ID号
		if (!handler.$$guid)
			handler.$$guid = addEvent.guid++;

		// 为元素建立一个事件类型散列表
		if (!element.events)
			element.events = {};

		// 为每个事件类型建立一个事件处理函数散列表
		var handlers = element.events[type];
		if (!handlers) {
			handlers = element.events[type] = {};

			// 存储已有的事件处理函数（如果存在一个）
			if (element["on" + type]) {
				handlers[0] = element["on" + type];
			}
		}

		// 按照ID号，将函数存储进处理函数散列表
		handlers[handler.$$guid] = handler;

		// 赋予一个全局的事件处理函数处理所有工作
		element["on" + type] = handleEvent;

	}

	// 创建独立ID计数器
	addEvent.guid = 1;

	function removeEvent(element, type, handler) {
		// 从列表中删除事件处理函数
		if (element.events && element.events[type]) {
			delete element.events[type][handler.$$guid];
		}
	}

	function handleEvent(event) {
		var returnValue = true;

		// 获取事件对象（IE使用全局对象）
		event = event || fixEvent(window.event);

		// 获取事件处理函数散列表的引用
		var handlers = this.events[event.type];

		// 依次执行每个事件处理函数
		for (var i in handlers) {
			this.$$handleEvent = handlers[i];
			if (this.$$handleEvent(event) === false) {
				returnValue = false;
			}
		}

		return returnValue;
	}

	// 增加一些IE事件对象缺乏的方法
	function fixEvent(event) {
		event.preventDefault = fixEvent.preventDefault;
		event.stopPropagation = fixEvent.stopPropagation;
		// 为window.event对象添加两个函数后返回给整个fixEvent对象
		return event;
	}

	fixEvent.preventDefault = function() {
		// 此函数由event调用，this指向event对象，而不管event = event 或event = fixEvent
		// 都是一样的，因为此时无论是event或者fixEvent对象都具有preventDefault方法。
		this.returnValue = false;
	};
	fixEvent.stopPropagation = function() {
		this.cancelBubble = true;
	};

	var _add_sheet = function() {
		var doc, cssCode;
		if (arguments.length == 1) {
			doc = document;
			cssCode = arguments[0];
		} else if (arguments.length == 2) {
			doc = arguments[0];
			cssCode = arguments[1];
		} else {
			alert("addSheet函数最多接受两个参数!");
		}
		var headElement = doc.getElementsByTagName("head")[0];
		var styleElements = headElement.getElementsByTagName("style");
		if (styleElements.length == 0) {/* 如果不存在style元素则创建 */
			if (!+"\v1") { // ie
				doc.createStyleSheet();
			} else {
				var tempStyleElement = doc.createElement('style');// w3c
				tempStyleElement.setAttribute("type", "text/css");
				headElement.appendChild(tempStyleElement);
			}
		}
		var styleElement = styleElements[0];
		var media = styleElement.getAttribute("media");
		if (media != null && !/screen/.test(media.toLowerCase())) {
			styleElement.setAttribute("media", "screen");
		}
		if (!+"\v1") { // ie
			styleElement.styleSheet.cssText += cssCode;
		} else if (/a/[-1] == 'a') {
			styleElement.innerHTML += cssCode;// 火狐支持直接innerHTML添加样式表字串
		} else {
			styleElement.appendChild(doc.createTextNode(cssCode))
		}
	};

	var isChrome = window.navigator.userAgent.indexOf("Chrome");
	var isFirefox = window.navigator.userAgent.indexOf("Firefox");
	// 禁止拖拽时选中兼容Chrome浏览器
	if (isChrome != -1) {
		_add_sheet("*,.QuickUI_Panel{\
			moz-user-select: -moz-none;\
			-moz-user-select: none;\
			-o-user-select:none;\
			-khtml-user-select:none;\
			-webkit-user-select:none;\
			-ms-user-select:none;\
			user-select:none;}");
	} else if (isFirefox != -1) {
		_add_sheet(".QuickUI_Panel{\
			moz-user-select: -moz-none;\
			-moz-user-select: none;\
			-o-user-select:none;\
			-khtml-user-select:none;\
			-webkit-user-select:none;\
			-ms-user-select:none;\
			user-select:none;}");
	}

})();


